package com.jfinal.plugin.radius;

import com.jfinal.plugin.radius.util.RadiusClient;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.IPlugin;

/**
 * RadiusPlugin.
 */
public class RadiusPlugin implements IPlugin {
	
	private String host;
	private String shared;
	
	public RadiusPlugin(String host, String shared) {
		if (StrKit.isBlank(host))
			throw new IllegalArgumentException("host can not be blank.");
		if (StrKit.isBlank(shared))
			throw new IllegalArgumentException("shared can not be blank.");
		this.host = host;
		this.shared = shared;
	}
	
	public boolean start() {
		Radius.mainClient = new RadiusClient(host, shared);
		return true;
	}
	
	public boolean stop() {
		Radius.mainClient.close();
		Radius.mainClient = null;
		return true;
	}
}


